package org.ywf.agent;

import java.util.HashMap;
import java.util.Map;


public enum URLEnum {

    //WEATHER_URL("9935283e5054ed3ed5d59dd13aa09796","http://apis.juhe.cn/simpleWeather/query","天气预报"),

    NEWS_URL("DCS001","8d11fde6dee43ae752dbbe9473b0a1e2","toutiao/index","新闻头条"),

    JOKE_URL("DCS002","9349ff9cc5a2909a68a68f277b037d05","joke/content/list.php","笑话大全")
    ;

    private String serverCode;

    private String authKey;

    private String httpUrl;

    private String discript;

    URLEnum(String serverCode, String authKey, String httpUrl, String discript) {
        this.serverCode = serverCode;
        this.authKey = authKey;
        this.httpUrl = httpUrl;
        this.discript = discript;
    }

    private static Map<String,URLEnum> mapCashe = new HashMap();

    static {
        for (URLEnum value : URLEnum.values()) {
            mapCashe.put(value.getServerCode(),value);
        }
    }

    /**
     * 静态方法，通过Key获取所有信息
     *
     * @param serverCode 服务编码
     * @return
     */
    public static URLEnum getUrlMap(String serverCode){
        return mapCashe.get(serverCode);
    }

    public String getServerCode() {
        return serverCode;
    }

    public void setServerCode(String serverCode) {
        this.serverCode = serverCode;
    }

    public String getAuthKey() {
        return authKey;
    }

    public void setAuthKey(String authKey) {
        this.authKey = authKey;
    }

    public String getHttpUrl() {
        return httpUrl;
    }

    public void setHttpUrl(String httpUrl) {
        this.httpUrl = httpUrl;
    }

    public String getDiscript() {
        return discript;
    }

    public void setDiscript(String discript) {
        this.discript = discript;
    }


    @Override
    public String toString() {
        return "URLEnum{" +
                "serverCode='" + serverCode + '\'' +
                ", authKey='" + authKey + '\'' +
                ", httpUrl='" + httpUrl + '\'' +
                ", discript='" + discript + '\'' +
                '}';
    }

    public static void main(String[] args) {
        URLEnum un = URLEnum.getUrlMap("DCS001");
        System.out.println("un:"+un.toString());
        System.out.println("un内容："+un.getAuthKey());
    }

}
